/*
 * JFrameSearchAdvanced.java
 *
 * Created on 31 de mayo de 2006, 1:16
 */

package fmap.gui;

import fmap.DatosCompartidos;
import fmap.dao.GroupFileDao;
import fmap.gui.actionListener.ListenerJFrameSearchAdvanced;
import fmap.utils.FormUtils;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.Vector;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JTextField;

/**
 *
 * @author  javi
 */
public class JFrameSearchAdvanced extends javax.swing.JFrame
{    
    
    /** Creates new form JFrameSearchAdvanced */
    public JFrameSearchAdvanced ()
    {
        initComponents ();
        
        Vector vGroupFile = new GroupFileDao ().selectGroupFile ();
        
        if( vGroupFile.size () > 0 )
        {

            DefaultComboBoxModel modelComboBox = new DefaultComboBoxModel();
            modelComboBox.addElement ( DatosCompartidos.getGroupFileSinFiltro () );
            for( int i=0; i<vGroupFile.size (); i++)
            {
                modelComboBox.addElement ( vGroupFile.get(i) );
            }

            comboBoxGroupFileSearch.setModel ( modelComboBox );
        }


        ListenerJFrameSearchAdvanced listener = new ListenerJFrameSearchAdvanced( this );
        
        buttonSearch.addActionListener ( listener );
        buttonCancelar.addActionListener ( listener );
        buttonGroupFile.addActionListener ( listener );
        
        this.addWindowListener ( new ListenerWindow () );
        FormUtils.centra(this);
    }
    
    public JTextField getTextFNameSearch()
    { return textFNameSearch; }
    public JTextField getTextFDateIniSearch()
    { return textFDateIniSearch; }
    public JTextField getTextFDateFinSearch()
    { return textFDateFinSearch; }
    public JTextField getTextFSizeIniSearch()
    { return textFSizeIniSearch; }
    public JTextField getTextFSizeFinSearch()
    { return textFSizeFinSearch; }
    public JComboBox getComboBoxTypeSizeSearch()
    { return comboBoxTypeSizeSearch; }
    public JComboBox getComboBoxGroupFileSearch()
    { return comboBoxGroupFileSearch; }
    public JTextField getTextFWordKeySearch()
    { return textFWordKeySearch; }
    public JTextField getTextFCommentSearch()
    { return textFCommentSearch; }
    public JCheckBox getCheckBoxCase()
    { return checkBoxCase;}



    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents()
    {
        jLabel8 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        textFDateIniSearch = new javax.swing.JTextField();
        comboBoxGroupFileSearch = new javax.swing.JComboBox();
        textFWordKeySearch = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        textFSizeFinSearch = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        textFSizeIniSearch = new javax.swing.JTextField();
        comboBoxTypeSizeSearch = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        textFCommentSearch = new javax.swing.JTextField();
        textFNameSearch = new javax.swing.JTextField();
        jSeparator1 = new javax.swing.JSeparator();
        buttonSearch = new javax.swing.JButton();
        buttonGroupFile = new javax.swing.JButton();
        buttonCancelar = new javax.swing.JButton();
        textFDateFinSearch = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        checkBoxCase = new javax.swing.JCheckBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Fmap - B\u00fasqueda avanzada");
        setAlwaysOnTop(true);
        jLabel8.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel8.setText("Selecciona tus criterios de b\u00fasqueda");

        jLabel4.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel4.setText("Fecha entre");

        jLabel6.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel6.setText("Grupo de ficheros");

        jLabel1.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel1.setText("Nombre");

        comboBoxGroupFileSearch.setFont(new java.awt.Font("Dialog", 0, 12));
        comboBoxGroupFileSearch.setPreferredSize(new java.awt.Dimension(183, 22));

        jLabel2.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel2.setText("Tama\u00f1o entre");

        jLabel3.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel3.setText("y");

        comboBoxTypeSizeSearch.setFont(new java.awt.Font("Dialog", 0, 12));
        comboBoxTypeSizeSearch.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "bytes", "kb", "mb", "gb" }));
        comboBoxTypeSizeSearch.setPreferredSize(new java.awt.Dimension(57, 19));

        jLabel5.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel5.setText("Palabras clave");

        jLabel7.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel7.setText("Comentarios");

        buttonSearch.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fmap/img/magnifier.png")));
        buttonSearch.setText("Buscar");
        buttonSearch.setActionCommand("buscar");
        buttonSearch.setMargin(new java.awt.Insets(2, 10, 2, 10));
        buttonSearch.setPreferredSize(new java.awt.Dimension(95, 23));

        buttonGroupFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fmap/img/cat_edit.png")));
        buttonGroupFile.setToolTipText("Editar grupos de ficheros");
        buttonGroupFile.setActionCommand("groupFile");
        buttonGroupFile.setPreferredSize(new java.awt.Dimension(50, 22));

        buttonCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fmap/img/cancel.png")));
        buttonCancelar.setText("Cancelar");
        buttonCancelar.setActionCommand("cancelar");
        buttonCancelar.setMargin(new java.awt.Insets(4, 10, 4, 10));
        buttonCancelar.setPreferredSize(new java.awt.Dimension(87, 23));

        jLabel9.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel9.setText("y");

        jLabel10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fmap/img/logo_2.png")));

        checkBoxCase.setText("Coincidir entre mayusculas / minusculas");
        checkBoxCase.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        checkBoxCase.setMargin(new java.awt.Insets(0, 0, 0, 0));

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel8)
                        .add(190, 190, 190)
                        .add(jLabel10)
                        .addContainerGap())
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jSeparator1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 443, Short.MAX_VALUE)
                    .add(layout.createSequentialGroup()
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(layout.createSequentialGroup()
                                .add(jLabel1)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(textFNameSearch, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE))
                            .add(layout.createSequentialGroup()
                                .add(116, 116, 116)
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(textFWordKeySearch, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)
                                    .add(textFCommentSearch, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)
                                    .add(checkBoxCase)))
                            .add(jLabel5)
                            .add(jLabel7)
                            .add(layout.createSequentialGroup()
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
                                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                            .add(jLabel4)
                                            .add(layout.createSequentialGroup()
                                                .add(jLabel2)
                                                .add(35, 35, 35)
                                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                                    .add(textFDateIniSearch, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 83, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                                    .add(textFSizeIniSearch, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 65, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                                            .add(jLabel9, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 14, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                            .add(jLabel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 14, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                            .add(layout.createSequentialGroup()
                                                .add(textFSizeFinSearch, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 68, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 13, Short.MAX_VALUE)
                                                .add(comboBoxTypeSizeSearch, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                            .add(textFDateFinSearch, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 89, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
                                        .add(jLabel6)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(comboBoxGroupFileSearch, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 259, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 24, Short.MAX_VALUE)
                                .add(buttonGroupFile, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 32, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap())
                    .add(layout.createSequentialGroup()
                        .add(191, 191, 191)
                        .add(buttonCancelar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 101, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 14, Short.MAX_VALUE)
                        .add(buttonSearch, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 125, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jLabel8)
                    .add(jLabel10))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jSeparator1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel1)
                    .add(textFNameSearch, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel4)
                    .add(jLabel9)
                    .add(textFDateFinSearch, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(textFDateIniSearch, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(textFSizeIniSearch, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel2)
                    .add(textFSizeFinSearch, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel3)
                    .add(comboBoxTypeSizeSearch, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(28, 28, 28)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel6)
                    .add(comboBoxGroupFileSearch, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(buttonGroupFile, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(25, 25, 25)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel5)
                    .add(textFWordKeySearch, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel7)
                    .add(textFCommentSearch, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(checkBoxCase)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 29, Short.MAX_VALUE)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(buttonCancelar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 28, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(buttonSearch, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 28, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents
    

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonCancelar;
    private javax.swing.JButton buttonGroupFile;
    private javax.swing.JButton buttonSearch;
    private javax.swing.JCheckBox checkBoxCase;
    private javax.swing.JComboBox comboBoxGroupFileSearch;
    private javax.swing.JComboBox comboBoxTypeSizeSearch;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTextField textFCommentSearch;
    private javax.swing.JTextField textFDateFinSearch;
    private javax.swing.JTextField textFDateIniSearch;
    private javax.swing.JTextField textFNameSearch;
    private javax.swing.JTextField textFSizeFinSearch;
    private javax.swing.JTextField textFSizeIniSearch;
    private javax.swing.JTextField textFWordKeySearch;
    // End of variables declaration//GEN-END:variables
    
    
    public class ListenerWindow implements WindowListener
    {
        // Constructor que guarda la referencia al objeto JFrame
        public ListenerWindow ()
        {}
        
        public void windowClosed ( WindowEvent evt )
        {
            // Cuando cerramos la ventana => activamos el jFrameMain
            DatosCompartidos.getJFrameMain ().activeComponents ();
            DatosCompartidos.getJFrameMain ().getButtonAdminCollection ().setEnabled ( true );
            
            DatosCompartidos.getJFrameMain ().getGlass ().setNeedToRedispatch (true);
            DatosCompartidos.getJFrameMain ().getGlass ().setVisible (false);
        }
        
        public void windowIconified ( WindowEvent evt )
        {}
        public void windowOpened ( WindowEvent evt )
        {
            // Cuando abrimos la ventana => desactivamos el jFrameMain
            DatosCompartidos.getJFrameMain ().desActiveComponents ();
            DatosCompartidos.getJFrameMain ().getButtonAdminCollection ().setEnabled ( false );
            DatosCompartidos.getJFrameMain ().setLblMsj ("");
            
            DatosCompartidos.getJFrameMain ().getGlass ().setNeedToRedispatch (false);
            DatosCompartidos.getJFrameMain ().getGlass ().setVisible (true);
        }
        public void windowClosing ( WindowEvent evt )
        {}
        public void windowDeiconified ( WindowEvent evt )
        {}
        public void windowActivated ( WindowEvent evt )
        {}
        public void windowDeactivated ( WindowEvent evt )
        {}
        
    }
}
